feat: implementation of the stdlib_datetime module#1148
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1148 +/- ##
==========================================
+ Coverage 68.00% 68.66% +0.66%
==========================================
Files 403 407 +4
Lines 12850 13599 +749
Branches 1383 1534 +151
==========================================
+ Hits 8738 9338 +600
- Misses 4112 4261 +149 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Implements an experimental stdlib_datetime module, along with build integration, documentation, examples, and a new test suite to validate date/time arithmetic, parsing/formatting, and calendar utilities.
Changes:
- Added
src/datetime/stdlib_datetime.f90providingdatetime_type/timedelta_type, arithmetic/comparison operators, ISO8601 parsing/formatting, and helper utilities. - Integrated the datetime component into the library build and added a datetime test target and example program.
- Added a new spec document describing the module API and supported behaviors.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
src/datetime/stdlib_datetime.f90 |
New datetime/timedelta types, operators, ISO parsing/formatting, and calendar utilities. |
src/datetime/CMakeLists.txt |
Adds the datetime library target and links it to core. |
src/CMakeLists.txt |
Adds datetime subdirectory and links it into the top-level stdlib target. |
test/datetime/test_datetime.f90 |
New unit tests for leap years, parsing/formatting, arithmetic, comparisons, and rollovers. |
test/datetime/CMakeLists.txt |
Registers datetime as a test target. |
test/CMakeLists.txt |
Adds datetime tests to the test build. |
example/datetime/example_datetime_usage.f90 |
New usage example demonstrating common API calls. |
example/datetime/CMakeLists.txt |
Registers datetime example target. |
example/CMakeLists.txt |
Adds datetime examples to the example build. |
doc/specs/stdlib_datetime.md |
New specification page describing the module API and formats. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
Hi @jalvesz, I have a few questions regarding the module implementation. Could you please walk me through them? Should timestamps without a designator |
|
Hi @jalvesz Just checking in to see if there's any additional information I can provide to help with the review process. Happy to make any necessary adjustments! |
jvdp1
left a comment
There was a problem hiding this comment.
Thank you @JAi-SATHVIK for this PR. A very complete set of procedures to handle dates an times IMO.
|
Hi @jvdp1, I've made the requested changes. can you please review the PR? |
Having a documented and standard default is a valid option. Can the timestamp designator be retrived from the OS ? that might be the better default.
I think users might want extra precision for seconds and miliseconds, and optional argument with a default ot 3 could be a good way of enabling user desired precision.
Would you mind explaining ? Just wondering, did you take some inspiration from the python datetime module https://docs.python.org/3/library/datetime.html ? |
|
Thanks for the feedback! I've updated the module to use
Inspiration: The |
jalvesz
left a comment
There was a problem hiding this comment.
LGTM @JAi-SATHVIK thanks for this nice new functionality!
jvdp1
left a comment
There was a problem hiding this comment.
Thank you @JAi-SATHVIK for this nice addition to stdlib!
|
Hi, thanks for the great work on this PR, it's really appreciated. I noticed the mention of potential
Do you currently plan to introduce these types as part of a follow-up, or is the intention to keep a single I'm asking because separating date and time can be quite useful in practice, but I understand it also comes with additional API complexity. Thanks! |
|
Hi @cyrilgandon, thanks for the feedback! I used a unified |
|
Hi, thanks for the clarification! One concrete use case on my side: I work on STICS, a crop modeling system with a daily time step. We only manipulate calendar dates (year, month, day), and time of day is irrelevant. In that context, a dedicated date_type would make the code clearer and avoid carrying unused time fields around. Looking forward to the follow-up PR 🙂 |
#1147